<template>

  <div class="app">
    <div class="box">
    <div class="demo-date-picker">
        <!-- 发布通知按钮 -->
      <div class="leave">
          <!-- <el-button type="primary" @click="router.push('/index/family-schoolInteraction/StudentLeaveList')">请假</el-button> -->
          <el-button text @click="dialogFormVisible" :icon="Edit">发布通知</el-button>
      </div>
      <div class="block">
          <!-- 快速搜索 -->
          <span>快速搜索：</span>
          <el-input v-model="input" placeholder="请输入通知类型" />
          <el-button text  @click="handleSelect(input)">查询</el-button>
          <el-button type="primary" @click="clear">重置</el-button>
      </div>
    </div>

    <el-table :data="$store.alertlistdata" border tooltip-effect="dark" stripe style="width: 100%" row-key>
      <el-table-column  prop="id" label="序号" width="100"  />
        <el-table-column prop="region" label="类型" width="180" />
        <el-table-column prop="name" label="标题" />
        <el-table-column prop="resource" label="发送范围" />
        <el-table-column prop="date1" label="发布时间" />
        <el-table-column prop="name" label="操作" >
            <template #default="scope">
                <el-button link type="primary" size="small" @click.prevent="deleteRow(scope.row)">删除</el-button>
            </template>
        </el-table-column>
  </el-table>
</div>
  </div>
</template>

<script setup>
import {alertliststore} from '../../../stores/counterzsq'
import {  Edit } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { onMounted, ref ,reactive} from 'vue'

let $store = alertliststore();

// 点击发布通知按钮就会跳转至发布按钮
var router = useRouter()
var dialogFormVisible = ()=>{
  router.push('/editelert');
}
//点击菜单项的回调, 通过参数path可以获取所点击的菜单项的index属性的值
var handleSelect = (path)=>{
  router.push(path);
}
const form = reactive({
  id:$store.alertlist.length,
  name: '',
  region: '',
  date1: '',
  date2: '',
  delivery: false,
  type: [],
  resource: '',
  desc: '',
})

// 快速搜索中输入框输入的内容
const input = ref('')
const dialogCkeakVisible = ref(false)

var handleSelect = (input)=>{
  $store.request_alertsearch(input)
}

var clear =()=>{
  input.value = ''
}
// 点击删除时删除本行数据
//定义函数
var deleteRow = (row)=>{
  $store.request_alertdelete(row);
}
</script>

<style scoped>

.app{
  background-color: #f7f7f7;
  padding: 25px 15px;
}

.box{
  background-color: white;
  padding: 20px 20px ;
}


.demo-date-picker {
  display: flex;
  justify-content: space-around;
  width: 100%;
  padding: 0;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.demo-date-picker .block {
  /* padding: 30px 0; */
  text-align: center;
  /* border-right: solid 1px var(--el-border-color); */
  flex: 1;
  width: 0;
  height: 30px;
  line-height: 30px;
  display: flex;
  justify-content: space-around;
}
.demo-date-picker .block:last-child {
  border-right: none;
}
.demo-date-picker .demonstration {
  display: block;
  color: var(--el-text-color-secondary);
  font-size: 14px;
  margin-bottom: 20px;
}
.el-range-editor.el-input__inner {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    /* margin: 0 50px; */
}
.el-date-picker{
    width: 300px;
    margin: 0 50px;

    /* margin: 0 20px; */
}
span{
    /* margin: 0 20px; */
    display: block;
    margin-right: 6px;
    margin-left: 500px;
    width: 600px;
}
.el-button{
    margin: 0 5px;
}
.leave{
    /* display: flex; */
    /* justify-content: flex-end; */
    margin: 5px 10px;
}
.teacher{
    height: 60px;
    line-height: 50px;
    margin:10px 0 20px 50px;
}
.checkleave{
    margin-left: 20px;
    font-size: 17px;
}
</style>